/**
 * task.js-
 */
import request from '../request'
class task {
  constructor() {
    this._defaultHeader = {
      'data-tupe': 'application/json'
    }
    this._request = new request
    this._request.setErrorHandler(this.errorHander)
  }

  /**
   * 统一的异常处理方法
   */
  errorHander(res) {
    console.error(res)
  }


  /**
   * 生成任务
   */
  addTask(data) {
    console.log(data, 32323233000)
    const app = getApp()
    return this._request.postRequest(app.globalData._baseUrl + 'sys/order/task/add-task', data).then(res => res.data)
  }
  /**
   * 提交任务
   */
  submitTask(data) {
    const app = getApp()
    return this._request.postRequest(app.globalData._baseUrl + 'sys/order/task/submit-task', data).then(res => res.data)
  }

  /**
   * 取消任务
   */
  cancelOrder(data) {
    const app = getApp()
    return this._request.postRequest(app.globalData._baseUrl + 'sys/order/cancel-order', data).then(res => res.data)
  }

    /**
   * 取消任务
   */
  expireOrder(data) {
    const app = getApp()
    return this._request.postRequest(app.globalData._baseUrl + 'sys/order/task/expire-order', data).then(res => res.data)
  }

  /**
   * 更新物资
   */
  updateGoods(data) {
    const app = getApp()
    return this._request.postRequest(app.globalData._baseUrl + 'sys/order/task/update-goods', data).then(res => res.data)
  }


  /**
   * 查询所有任务
   */
  getTaskDetail(data) {
    const app = getApp()
    return this._request.getRequest(app.globalData._baseUrl + 'sys/order/task/get-task-detail', data).then(res => res.data)
  }

  getPaySettings(data) {
    const app = getApp()
    return this._request.getRequest(app.globalData._baseUrl + 'sys/pay/get-pay-settings', data).then(res => res.data)
  }

  /**
   * 查询状态变更
   */
  getTaskStatusLog(data) {
    const app = getApp()
    return this._request.getRequest(app.globalData._baseUrl + 'sys/order/task/get-task-status-log', data).then(res => res.data)
  }
}
export default task